package com.test.www.utils.db.factory;

public abstract class Operation {
    private double value1 = 0;
    private double value2 = 0;

    public double getValue1() {
        return value1;
    }

    public void setValue1(double value1) {
        this.value1 = value1;
    }

    public double getValue2() {
        return value2;
    }

    public void setValue2(double value2) {
        this.value2 = value2;
    }
    public abstract double getResule();
}

//加法
class OperationAdd extends Operation {

    @Override
    public double getResule() {
        return getValue1() + getValue2();
    }
}

//减法
class OperationSub extends Operation {

    @Override
    public double getResule() {
        return getValue1() - getValue2();
    }
}

//乘法
class OperationMul extends Operation {

    @Override
    public double getResule() {
        return getValue1() * getValue2();
    }
}

//除法
class OperationDiv extends Operation {

    @Override
    public double getResule() {
        if (getValue2() != 0) {
            return getValue1() / getValue2();
        }
        throw new IllegalArgumentException("除数不能为零");
    }
}

